package com.wiwf.model.security.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.wiwf.model.bean.SysUserBean;
import com.wiwf.model.security.service.SysUserService;

/**
 * @author kehui
 */
@Service
public class CustomUserDetailsServiceImpl implements UserDetailsService {
	
	@Autowired
	private SysUserService userService;
	
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		
		SysUserBean userInfo = userService.getUser(username);
        if (userInfo == null) {
            throw new UsernameNotFoundException("用户不存在");
        }
		
		return userInfo;
	}

}
